package com.fire.control.system.entity;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.fasterxml.jackson.annotation.JsonManagedReference;
import com.fire.control.system.statics.Status_Online;

/****
 * 
 * @ClassName:  Device   
 * @Description:设备信息
 * @author:   chenchuang
 * @date:   2017年5月6日 下午2:56:50   
 *
 */
@Entity
@Table(name = "t_device") 
public class Device extends BaseEntity{

	private static final long serialVersionUID = 1L;
	
	/**   
	 * @Fields deviceName : 设备名称   
	 */ 
	@Column(name = "device_name", nullable = false,length=50)
	private String deviceName;
	
	/**   
	 * @Fields deviceType : 设备类型
	 */ 
	@ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name="device_type",nullable = false )
	private DeviceType deviceType;
	
	@Column(name = "online_status", nullable = false,length=20)
	@Enumerated(EnumType.STRING)
	private Status_Online onlineStatus;
	
	/**
	 * @Fields securityManager : 安全管理员
	 */
	@ManyToOne(cascade={CascadeType.REFRESH},fetch=FetchType.EAGER,optional=false)  
	@JoinColumn(name="manager_user_id")  
	private User securityManager;
	
	/**
	 * @Fields securityManager : 安全巡检员
	 */
	@ManyToOne(cascade={CascadeType.REFRESH},fetch=FetchType.EAGER,optional=false)  
	@JoinColumn(name="patrol_user_id")  
	private User securityPatrol;
	
	
	/**   
	 * @Fields company : 归属公司企业
	 */
	@JsonManagedReference
	@ManyToOne(cascade={CascadeType.REFRESH},fetch=FetchType.EAGER,optional=false)  
	@JoinColumn(name="company_id")  
	private Company company;
	
	/**   
	 * @Fields serialNumber : 序列号
	 */ 
	@Column(name = "serial_number", nullable = false,length=50)
	private String serialNumber;
	
	/**   
	 * @Fields address : 所在地址
	 */ 
	@Column(name = "address", nullable = false,length=50)
	private String address;
	
	/**   
	 * @Fields longitude : 经度
	 */ 
	@Column(name = "longitude")
	private Double longitude;
	
	/**   
	 * @Fields latitude : 纬度
	 */ 
	@Column(name = "latitude")
	private Double latitude;
	
	/**   
	 * @Fields sideX : 侧面位置x轴，用于建筑侧面图
	 */ 
	@Column(name = "side_x")
	private String sideX;
	
	/**   
	 * @Fields sideY : 侧面位置y轴，用于建筑侧面图
	 */ 
	@Column(name = "side_y")
	private String sideY;
	
	/**   
	 * @Fields sideUrl : 平面图地址
	 */ 
	@Transient
	private String sideUrl;
	
	/**   
	 * @Fields planeX : 建筑平面图X轴
	 */ 
	@Column(name = "plane_x")
	private String planeX;
	
	/**   
	 * @Fields planeY : 建筑平面图y轴
	 */ 
	@Column(name = "plane_y")
	private String planeY;
	
	/**   
	 * @Fields planUrl : 平面图地址
	 */ 
	@Column(name = "plan_url")
	private String planUrl;
	
	/**   
	 * @Fields floorMax : 最大楼层   
	 */ 
	@Column(name = "floor_max")
	private Integer floorMax;
	
	/**   
	 * @Fields floor : 所在楼层   
	 */ 
	@Column(name = "floor")
	private Integer floor;
	
	/**   
	 * @Fields location : 区域  
	 */ 
	@JsonManagedReference
	@OneToOne(cascade={CascadeType.REFRESH},fetch=FetchType.EAGER,optional=false)  
	@JoinColumn(name="area_id")
	private Area area;
	
	@Column(name = "province_id")
	private String provinceId;//省
	
	@Column(name = "city_id")
	private String cityId;//市
	
	/**   
	 * @Fields location : 楼栋位置
	 */ 
	@Column(name = "building", nullable = false,length=100)
	private String building;
	
	/**   
	 * @Fields location : 业主
	 */ 
	@Column(name = "owner", nullable = false,length=20)
	private String owner;
	
	/**   
	 * @Fields location : 联系电话
	 */ 
	@Column(name = "phone", nullable = false,length=15)
	private String phone;
	
	/**   
	 * @Fields location : 平面图id
	 */ 
	@Column(name = "plan_id")
	private String planId;
	
	/**   
	 * @Fields location : 侧面图id
	 */ 
	@Column(name = "side_id")
	private String sideId;
	
	@Transient
	private String companyId;
	
	// 设备组id
	@Transient
	private String groupId;
	
	@JsonManagedReference
	@ManyToOne(cascade={CascadeType.REFRESH}, fetch=FetchType.LAZY,optional=false)
	@JoinColumn(name = "middleware_id")
	private Middleware middleware;
	
	@JsonManagedReference
	@ManyToOne(fetch=FetchType.LAZY,optional=false)
	@JoinColumn(name = "device_group_id")
	private DeviceGroup deviceGroup;
	
	@JsonManagedReference
	@ManyToOne(fetch=FetchType.LAZY,optional=false)
	@JoinColumn(name = "gateway_id")
	private Gateway gateway;
	
	
	
	public Gateway getGateway() {
		return gateway;
	}

	public void setGateway(Gateway gateway) {
		this.gateway = gateway;
	}

	public String getCompanyId() {
		return companyId;
	}

	public void setCompanyId(String companyId) {
		this.companyId = companyId;
	}
	
	public User getSecurityManager() {
		return securityManager;
	}

	public void setSecurityManager(User securityManager) {
		this.securityManager = securityManager;
	}

	public User getSecurityPatrol() {
		return securityPatrol;
	}

	public void setSecurityPatrol(User securityPatrol) {
		this.securityPatrol = securityPatrol;
	}

	public String getBuilding() {
		return building;
	}

	public void setBuilding(String building) {
		this.building = building;
	}

	public String getOwner() {
		return owner;
	}

	public void setOwner(String owner) {
		this.owner = owner;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getPlanId() {
		return planId;
	}

	public void setPlanId(String planId) {
		this.planId = planId;
	}

	public String getSideId() {
		return sideId;
	}

	public void setSideId(String sideId) {
		this.sideId = sideId;
	}

	public Status_Online getOnlineStatus() {
		return onlineStatus;
	}

	public void setOnlineStatus(Status_Online onlineStatus) {
		this.onlineStatus = onlineStatus;
	}

	public DeviceGroup getDeviceGroup() {
		return deviceGroup;
	}

	public void setDeviceGroup(DeviceGroup deviceGroup) {
		this.deviceGroup = deviceGroup;
	}

	public String getDeviceName() {
		return deviceName;
	}

	public void setDeviceName(String deviceName) {
		this.deviceName = deviceName;
	}



	public DeviceType getDeviceType() {
		return deviceType;
	}

	public void setDeviceType(DeviceType deviceType) {
		this.deviceType = deviceType;
	}

	public Area getArea() {
		return area;
	}

	public void setArea(Area area) {
		this.area = area;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}


	public String getSerialNumber() {
		return serialNumber;
	}

	public void setSerialNumber(String serialNumber) {
		this.serialNumber = serialNumber;
	}

	public Company getCompany() {
		return company;
	}

	public void setCompany(Company company) {
		this.company = company;
	}

	public String getSideX() {
		return sideX;
	}

	public void setSideX(String sideX) {
		this.sideX = sideX;
	}

	public String getSideY() {
		return sideY;
	}

	public void setSideY(String sideY) {
		this.sideY = sideY;
	}

	public String getPlaneX() {
		return planeX;
	}

	public void setPlaneX(String planeX) {
		this.planeX = planeX;
	}

	public String getPlaneY() {
		return planeY;
	}

	public void setPlaneY(String planeY) {
		this.planeY = planeY;
	}

	public String getPlanUrl() {
		return planUrl;
	}

	public void setPlanUrl(String planUrl) {
		this.planUrl = planUrl;
	}

	public Integer getFloorMax() {
		return floorMax;
	}

	public void setFloorMax(Integer floorMax) {
		this.floorMax = floorMax;
	}

	public Integer getFloor() {
		return floor;
	}

	public void setFloor(Integer floor) {
		this.floor = floor;
	}

	public String getGroupId() {
		return groupId;
	}

	public void setGroupId(String groupId) {
		this.groupId = groupId;
	}

	public String getSideUrl() {
		return sideUrl;
	}

	public void setSideUrl(String sideUrl) {
		this.sideUrl = sideUrl;
	}

	public Double getLongitude() {
		return longitude;
	}

	public void setLongitude(Double longitude) {
		this.longitude = longitude;
	}

	public Double getLatitude() {
		return latitude;
	}

	public void setLatitude(Double latitude) {
		this.latitude = latitude;
	}

	public Middleware getMiddleware() {
		return middleware;
	}

	public void setMiddleware(Middleware middleware) {
		this.middleware = middleware;
	}

	public String getProvinceId() {
		return provinceId;
	}

	public void setProvinceId(String provinceId) {
		this.provinceId = provinceId;
	}

	public String getCityId() {
		return cityId;
	}

	public void setCityId(String cityId) {
		this.cityId = cityId;
	}

	
}
